<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>订单号：</label>
                                <input type="text" name="orderNo"/>
                            </li>
                            <li>
                                <label>客户ID：</label>
                                <input type="text" name="customerId"/>
                            </li>
                            <li>
                                <label>订单类型：</label>
                                <select name="type" th:with="type=${@dict.getType('orderType')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>订单充电结束类型：</label>
                                <select name="re" th:with="type=${@dict.getType('chargeReportStatus')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>客户手机号：</label>
                                <input type="text" name="customerPhone"/>
                            </li>
                            <li>
                                <label>设备编号：</label>
                                <input type="text" name="deviceSn"/>
                            </li>
                            <li>
                                <label>支付交易号：</label>
                                <input type="text" name="tranNo"/>
                            </li>
                            <li>
                                <label>支付方式：</label>
                                <select name="payType" th:with="type=${@dict.getType('orderPayMethod')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>是否已分成：</label>
                                <select name="shareStatus" th:with="type=${@dict.getType('yesOrNo')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>订单支付状态：</label>
                                <select name="payStatus" th:with="type=${@dict.getType('orderPayStatus')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>订单状态：</label>
                                <select name="status" th:with="type=${@dict.getType('orderStatus')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>是否启用：</label>
                                <select name="enable" th:with="type=${@dict.getType('enableStatus')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>来源：</label>
                                <select name="source" th:with="type=${@dict.getType('dataSource')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="biz:order:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="biz:order:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="biz:order:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: bootstrap-table-fixed-columns-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('biz:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('biz:order:remove')}]];
        var closeFlag = [[${@permission.hasPermi('biz:order:close')}]];
        var typeDatas = [[${@dict.getType('orderType')}]];
        var deviceTypeDatas = [[${@dict.getType('deviceType')}]];
        var payTypeDatas = [[${@dict.getType('orderPayMethod')}]];
        var shareStatusDatas = [[${@dict.getType('yesOrNo')}]];
        var payStatusDatas = [[${@dict.getType('orderPayStatus')}]];
        var statusDatas = [[${@dict.getType('orderStatus')}]];
        var enableDatas = [[${@dict.getType('enableStatus')}]];
        var sourceDatas = [[${@dict.getType('dataSource')}]];
        var prefix = ctx + "biz/order";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                fixedColumns: true,
                fixedRightNumber: 1,
                sortName: "id",
                sortOrder: "desc",
                modalName: "订单",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'tenantId',
                    title: '租户标识',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'orderNo',
                    title: '订单号',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'type',
                    title: '订单类型',
                    visible: false,
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'customerId',
                    title: '客户ID',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'customerAccount',
                    title: '客户账号',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'customerPhone',
                    title: '客户手机号',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'deviceId',
                    title: '设备ID',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'deviceType',
                    title: '设备类型',
                    visible: false,
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(deviceTypeDatas, value);
                    }
                },
                {
                    field: 'deviceSn',
                    title: '设备编号',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 15, 'open');
                    }
                },
                {
                    field: 'deviceDiscount',
                    title: '设备折扣(%)',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'siteId',
                    title: '场地ID',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'siteName',
                    title: '场地名称',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'sitePosition',
                    title: '场地位置',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'couponId',
                    title: '优惠券ID',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'couponTitle',
                    title: '优惠券标题',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'couponAmount',
                    title: '优惠金额',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'amount',
                    title: '订单金额',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'tranNo',
                    title: '支付交易号',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'payType',
                    title: '支付方式',
                    visible: false,
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(payTypeDatas, value);
                    }
                },
                {
                    field: 'payAmount',
                    title: '支付金额',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'payTime',
                    title: '支付时间',
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'payStatus',
                    title: '订单支付状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(payStatusDatas, value);
                    }
                },
                {
                    field: 'status',
                    title: '订单状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'shareStatus',
                    title: '是否已分成',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(shareStatusDatas, value);
                    }
                },
                {
                    field: 'enable',
                    title: '是否启用',
                    visible: false,
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(enableDatas, value);
                    }
                },
                {
                    field: 'source',
                    title: '来源',
                    visible: false,
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(sourceDatas, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'successTime',
                    title: '完成时间',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a style="margin-top: 3px;" class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="amountList(\'' + row.orderNo + '\')"><i class="fa fa-rmb"></i> 订单交易流水</a> ');
                        actions.push('<a style="margin-top: 3px;" class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="goods(\'' + row.orderNo + '\')"><i class="fa fa-history"></i> 订单实时数据</a> ');
                        actions.push('<a style="margin-top: 3px;" class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.id + '\')"><i class="fa fa-search"></i> 详情</a> ');
                        if(row.status == 'goOn'){
                            actions.push('<a style="margin-top: 3px;" class="btn btn-danger btn-xs ' + closeFlag + '" href="javascript:void(0)" onclick="closeOrder(\'' + row.id + '\')"><i class="fa fa-power-off"></i> 关闭订单</a> ');
                        }
                        // actions.push('<a style="margin-top: 3px;" class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i> 删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function detail(id) {
            var url = prefix + '/detail/' + id + "?time=" + (new Date()).getTime();
            $.modal.openTab("订单详情", url);
        }
        /**
         * 停止充电测试
         */
        function closeOrder(id){
            $.modal.confirm("确定关闭该订单吗？", function() {
                $.operate.get(prefix + "/close?id="+id);
            })

        }
        /**
         * 订单交易流水
         * @param id
         */
        function amountList(orderNo){
            var url = ctx + '/biz/tranlog?orderNo=' + orderNo;
            $.modal.openTab("订单["+orderNo+"]订单交易流水", url);
        }
        /**
         * 订单电费
         * @param id
         */
        function goods(orderNo){
            var url = ctx + '/biz/realtimedata?orderNo=' + orderNo;
            $.modal.openTab("订单["+orderNo+"]实时数据", url);
        }

    </script>
</body>
</html>